package com.lee;

/**
 * @Description TODO
 */
public class RecordPatternsTest {
    public static void main(String[] args) {
        record Person(String name, int age) {
            Person {
                if (age < 0) {
                    throw new IllegalArgumentException("age < 0");
                }
            }
        }

//        var person = new Person("a", -1);
        var person = new Person("a", 1);
        if(person instanceof Person p){
            System.out.println(p.name());
            System.out.println(p.age());
        }
    }
}
